/**
 * 岗位信息管理
 */
import React from 'react';
import { Card, Row, Col, Typography } from 'antd';
import AuthComponent from '@/utils/auth/AuthComponent';
import { router, withRouter } from 'umi';
import { Icon } from '../../components';

function PostCard(props) {
    const { location, data = {}, loading } = props;
    const { query } = location;

    const {
        dutyName = '--',
        workYearsName = '--',
        recruitDegreeName = '--',
        workCity = '--',
        workNatureName = '--',
        recruitNums = '--',
        minSalary = '',
        maxSalary = '',
        companyCurrencyCode = ''
    } = data;

    const money = !minSalary || !maxSalary ? '--' : `${minSalary} K ~ ${maxSalary} K`;

    return (
        <Card
            title="岗位对外信息"
            bordered={false}
            style={{ margin: 16, marginTop: 0 }}
            loading={loading}
            extra={
                <AuthComponent code="office:recruitment:channel:outward:edit">
                    <Icon
                        title="编辑"
                        type="listfunction_edit_icon_default"
                        onClick={() => {
                            history.push(
                                `/office/personnelManagement/recruitment/channel/post/form?recruitCode=${query.recruitCode}`
                            );
                        }}
                        style={{ fontWeight: 'normal', fontSize: 20, cursor: 'pointer' }}
                    />
                </AuthComponent>
            }
        >
            <Row style={{ marginTop: 8 }} gutter={26}>
                <Col span={8}>
                    <Typography.Text>岗位名称：{dutyName}</Typography.Text>
                </Col>
                <Col span={8}>
                    <Typography.Text>经验学历：{`${workYearsName}/${recruitDegreeName}`}</Typography.Text>
                </Col>
                <Col span={8}>
                    <Typography.Text>工作城市：{workCity}</Typography.Text>
                </Col>
            </Row>
            <Row style={{ marginTop: 16 }} gutter={26}>
                <Col span={8}>
                    <Typography.Text>工作性质：{workNatureName}</Typography.Text>
                </Col>
                <Col span={8}>
                    <Typography.Text>需求人数：{recruitNums}</Typography.Text>
                </Col>
                <Col span={8}>
                    <Typography.Text>
                        薪资范围：{money} {companyCurrencyCode}
                    </Typography.Text>
                </Col>
            </Row>
        </Card>
    );
}

export default withRouter(PostCard);
